<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>题库管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>组件</cite></a>
    <a><cite>数据表格</cite></a>
    <a><cite>题库管理</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header">用户日志</div>
        <div class="layui-card-body">

          <div class="test-table-reload-btn layui-form-item" style="margin-bottom: 10px;">
            姓名：
            <div class="layui-inline">
              <input class="layui-input" name="name" autocomplete="off">
            </div>
            登陆账号：
            <div class="layui-inline">
              <input class="layui-input" name="username" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
          </div>

          <table class="layui-hide" id="table-log" lay-filter="test-table-toolbar"></table>

          <script type="text/html" id="table-log-list">
            <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
          </script>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    editData = [];
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var admin = layui.admin
            ,table = layui.table
            ,$ = layui.$
            ,form = layui.form;

        table.render({
            elem: '#table-log'
            ,url: '/admin/log/logs'
            ,page: true
            ,limit : 10
            ,limits: [10,30,60,90]
            ,loading: true   //开启翻页加载动画
            ,toolbar: '#table-log-toolbar'   //开启toolbar
            //,height: 'full-100' //高度最大自适应
            ,cols: [[
                {field:'logId',  title: 'ID', sort: true,hide:true}
                ,{field:'username',  title: '登陆账号',width:120,align:'center'}
                ,{field:'name',  title: '姓名',width:120,align:'center'}
                ,{field:'operation',  title: '用户操作',width:120}
                ,{field:'time',  title: '响应时间', sort: true,width:100,align:'center'}
                ,{field:'method',  title: '请求方法'}
                ,{field:'params',  title: '参数'}
                ,{field:'ip',  title: 'ip',width:160}
                ,{field:'createTime',  title: '请求时间', sort: true,width:180}
            ]]

        });

        //头工具栏事件
        table.on('toolbar(test-table-toolbar)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            if(obj.event === 'add'){
                bankAdd();
            }
        });

        //搜索
        var active = {
            reload: function(){
                //执行重载
                table.reload('table-log', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        name: $('[name=name]').val(),
                        username: $('[name=username]').val()
                    }
                });
            }
        };

        $('.test-table-reload-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>
</body>
</html>